<?php

namespace App\Models\finance;

use App\Models\AdminModel;
use App\Models\AgentModel;
use App\Models\TakeOrderModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class PayableAirlineModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_payble_airline';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];

    // 状态常量
    const STATUS_UNPAID = 1;      // 未付款
    const STATUS_PART_PAID = 2;   // 部分付款
    const STATUS_PAID = 3;        // 已付款

    const STATUS_LIST = [
        self::STATUS_UNPAID => '未付款',
        self::STATUS_PART_PAID => '部分付款',
        self::STATUS_PAID => '已付款',
    ];

    // 关联供应商
    public function agent(): BelongsTo 
    {
        return $this->belongsTo(AgentModel::class, 'agent_id');
    }

    // 关联主单
    public function takeOrder(): BelongsTo 
    {
        return $this->belongsTo(TakeOrderModel::class, 'take_order_id');
    }

    // 关联创建人
    public function createAdmin(): BelongsTo 
    {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }
} 